<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<script src="js/jquery-1.5.1.min.js"></script>
	<script src="js/jquery-ui-1.8.13.custom.min.js"></script>
	<link type="text/css" href="css/ui-lightness/jquery-ui-1.8.13.custom.css" rel="stylesheet" />
	<script>
		$(function() {
			$( "#tabs" ).tabs();
		});
	</script>
	
<?php
session_start();

if (isset($_POST['submit'])) {
	$username = $_POST['username'];
	$password = $_POST['password'];
	$login = array(
		'username' => $username,
		'password' => $password
	);
	$login_json = json_encode($login);
	$_SESSION['login_json'] = $login_json;
	echo print_r($login_json);
	header ('location: checklogin.php');
}
?>

</head>
<body>
<div id="tabs">

	<ul>
		<li><a href="#tabs-1">Home</a></li>
		<li><a href="#tabs-2">Event Info</a></li>
		<li><a href="#tabs-3">Evaluation</a></li>
	</ul>
	
	<div id="tabs-1">
<?php
if (isset($_SESSION['isLogin']) && ($_SESSION['isLogin'] == 1)) {
	$user_info_json = $_SESSION['user_info_json'];
	$user_info = json_decode($user_info_json, true);
	$pmi = $user_info['pmi_id'];
	$pdu = $user_info['pdu'];
	
	$chapter_name_json = $_SESSION['chapter_name_json'];
	$chapter_info = json_decode($chapter_name_json, true);
	$chapter_num = sizeof($chapter_info);
	
	echo "<button onclick='javascript:session.removeall();'>Logout</button>";
	
	echo "<form action='' method='POST'>";
	echo 	"<table>";
	echo		"<tr>";
	echo			"<td>PMI ID</td>";
	echo			"<td>$pmi</td>";
	echo		"</tr>";
	echo		"<tr>";
	echo			"<td>PDU</td>";
	echo			"<td>$pdu</td>";
	echo		"</tr>";
	echo		"<tr>";
	echo			"<td>Chapter</td>";
	echo			"<td><select name='chapter'>";
	for ($i = 0; $i < $chapter_num; $i++) {
		$chapter_name = $chapter_info[$i];
		echo			"<option value='$chapter_name'>$chapter_name</option>";
	}
	echo			"</select></td>";
	echo	"</table>";
	echo "</form>"
?>
		
<?php
} else {
?>
		<form action="" method="POST">
			<table>
				<tr>
					<td>Login</td>
					<td><input type="text" name="username" /></td>
				</tr>
				<tr>
					<td>Password</td>
					<td><input type="text" name="password" /></td>
				</tr>
				<tr>
					<td></td>
					<td><input type="submit" name="submit" /></td>
				</tr>
			</table>
		</form>
<?php
}
?>
	</div>
	
	<div id="tabs-2">
		
	</div>
	
	<div id="tabs-3">
	
	</div>
	
</div>
</body>

</html>